Lab 00 - ROS recap

Robotics II

Poznan University of Technology, Institute of Robotics and Machine Intelligence

Laboratory 0: A recap of Robot Operating System 2 usage

Back to the course table of contents

Installation

The installation steps for ROS2 are available in the following links: ROS2 Foxy for Ubuntu 20.04, ROS Humble for Ubuntu 22.04 or ROS Jazzy for Ubuntu 24.04.

Alternatively, you can use prepared containers: osrf/ros:foxy-desktop-full, osrf/ros:humble-desktop-full or osrf/ros:jazzy-desktop-full.

Basic concepts

Source: https://automaticaddison.com/ros-2-architecture-overview/

Usage

Below are some tips to remind you how to use ROS2 in the terminal.

Workspace

Frequently, all ROS2-related activities are performed in the created directory: ~/ros2_ws/. In this example, the ~/ros2_ws/src/ subdirectory contains the project codes.

$ colcon build
$ source install/setup.bash

Executions

ROS 2 nodes start automatically and discover each other.

$ ros2 run <package_name> <executable>
i.e. $ ros2 run demo_nodes_cpp talker
$ ros2 launch <package_name> <launch_file.py>
i.e. $ ros2 launch demo_nodes_cpp talker_listener.launch.py

Topics

$ ros2 topic list
$ ros2 topic info <topic_name>
$ ros2 topic echo <topic_name>
$ ros2 topic pub <topic_name> <msg_type> "<message>"


for example:
  $ ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.5}, angular: {z: 0.2}}"

Services

$ ros2 service list
$ ros2 service type <service_name>
$ ros2 service call <service_name> <service_type> "<request>"

i.e. $ ros2 service call /reset std_srvs/srv/Empty "{}"

Tools

Rosbag

Rosbag allows you to record (rosbag record) and replay (rosbag play) the status of your robotic system.

Rviz

Rviz allows you to visualise topics.

$ ros2 run rviz2 rviz2

Rqt_plot

Rqt_plot allows you to draw graphs for topics.

$ ros2 run rqt_plot rqt_plot

Rqt_graph

Rqt_graph allows the graphical visualisation of topical calls.

$ ros2 run rqt_graph rqt_graph